<template>
    <div>
        <van-nav-bar title="我的基本信息" left-text="返回" left-arrow @click-left="proxy.$leftClick" />
        <van-cell-group>
            <template  v-for="item in Object.keys(store.zlData)">
                <van-cell :title="item" :value="store.zlData[item as T]" />
            </template>
            
        </van-cell-group>
    </div>
</template>

<script setup lang="ts">
import { getCurrentInstance,onBeforeMount } from 'vue';
import { useMy } from '../store/my'
import { useRouter } from 'vue-router';
type T = keyof myInObj
const { proxy }: any = getCurrentInstance();
const store = useMy();
const router = useRouter();

onBeforeMount(async ()=>{
    // 当个人资料信息页面渲染前 通过my的pinia接口来进行数据拉取
    let res =await store.fetchMyData();
    if(res){
        // 如果res为true 证明不存在用户 跳转到登录页
        router.push({name:'denglu'})
    }
})
</script>